/*
 * File:   ipc_controller.h
 * Author: dolphinigle
 *
 * Created on December 2, 2011, 4:13 PM
 */

#ifndef IPC_CONTROLLER_MOCK_H
#define	IPC_CONTROLLER_MOCK_H

#include <string>
#include <cassert>
#include <queue>
using std::string;
using std::queue;

#include "ipc_controller_interface.h"

// I'm sorry for putting a GLOBAL VARIABLE!!!!!

extern queue<string> IsExistReturn_;

/**
 * Sends command to file system through IPC.
 */
class IPCControllerMock : public IPCControllerInterface {
public:
  IPCControllerMock() {}

  virtual bool IsExist(const string& path) {
    assert(!IsExistReturn_.empty());
    string ret = IsExistReturn_.front();
    IsExistReturn_.pop();
    return ret == "YES";
  }

  virtual string Ls(const string& path) {
    return "ls " + path;
  }
  virtual string Mkdir(const string& path) {
    return "mkdir " + path;
  }
  virtual string Rm(const string& path) {
    return "rm " + path;
  }
  virtual string Cp1(const string& path, const string& real_path) {
    return "cp1 " + path + " " + real_path;
  }
  virtual string Cp2(const string& real_path, const string& path) {
    return "cp2 " + real_path + " " + path;
  }
  virtual string Cat(const string& path) {
    return "cat " + path;
  }
  virtual string Close() {
    return "umount";
  }
  virtual string Status() {
    return "status";
  }

private:
  void AssertEqual(string& expected, const string& actual) {
    assert(expected != "");
    assert(expected == actual);
    expected = "";
  }
};

#endif	/* IPC_CONTROLLER_MOCK_H */

